<!DOCTYPE html>

<head>
    <meta charset="UTF-8">
    <title>crawler</title>
    <script src="${request.contextPath}/statics/libs/jquery.min.js"></script>

</head>
<body>
<p>欢迎使用crawler爬虫工具</p>
查询的网站：<input type="text" id="inpt"  placeholder="有种你就填">
<input type="button" onclick="saveOrUpdate()" value="确定"/>
<script>
    $(function () {

    })
    var cont =0;
    var isok =true;

    function saveOrUpdate() {
        setInterval('saveOrUpdatexun()', 1000); ;
        //saveOrUpdatexun();
    }
    function saveOrUpdatexun(){
        console.log("xunhuan+++++++++++++++")
        if(isok){
            $.ajax({
                type: "POST",
                url:"/api/crawler/renwu",
                async: false,
                cache: true,
                //contentType: "application/json",
                data:{crawlurl:"http://baike.1kuang.com/baike-"+cont+".html"},
                success: function(r){
                    if(r.code == 0){
                        cont++;
                        isok=true;
                        console.log("asaaaaaaaaa+cont::"+cont+"       zhaugtissn:::::::"+isok);
                        //saveOrUpdatexun2();
                    }else{
                        alert(r.msg);
                    }
                },
                beforeSend:function () {
                    isok=false;
                    console.log("开始发送：：：cont："+cont+"       zhaugtissn:::::::"+isok);

                }
            });
        }
    }
    function saveOrUpdatexun2(){
        $.ajax({
            type: "POST",
            url:"/api/crawler/detail",
            async: false,
            cache: true,
            //contentType: "application/json",
            data:{crawlurl:"https://www.xianjichina.com/baike/detail_"+cont+".html"},
            success: function(r){
                if(r.code == 0){
                    cont++;
                    console.log("asaaaaaaaaa+cont22222222222222::"+cont);
                    saveOrUpdatexun();
                }else{
                    alert(r.msg);
                }
            },
            beforeSend:function () {
                console.log("开始发送：：：cont："+cont);
            }
        });
    }
</script>
</body>
</html>